<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/resources/js/datatable-query.js"></script>

<div class="row-fluid">
<div class="span12">
<div class="box gradient">
<div class="title">
<h4><span>Page</span></h4>

<a href="#" class="minimize">Minimize</a></div>
<div class="content scrollable clearfix">
<table class="ajaxTable display table table-bordered">
	<thead>
		<tr>
			<th><a id="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
 			<th>Name</th>
 			<th>Title</th>
			<th>Page Template</th>
			<th>Online</th>
			<th>Visit Path</th>
			<th>Action</th>
		</tr>
	</thead>
</table>
</div>
</div>
</div>
</div>
<div>
<script type="text/javascript">

var render = false;
 
$(document).ready(function () {
	johnny.oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"aoColumnDefs": [
			       		  { 'bSortable': false, 'aTargets': [0,6] }
			       		],
		"sAjaxSource": '${ctx}/admin/channel/',
		"fnInitComplete": function (oSettings, json) { }
	});
	var name = $("<input>").attr({
		type: "text",
		field: "name",
		op: "cn",
		placeholder: "Page Name",
		class: "filterdata"
	});
	johnny.initTableQuery(name);
	var config = {
			id : 'del',
			text  : 'Del',
			domain : "Page ",
			operation : "Delete",
			url : "${ctx}/admin/channel/del/"
	};
	johnny.tableBtn(config);
	
	var online = {
			id : 'online',
			text  : 'Online',
			domain : "Page",
			operation : "Online",
			url : "${ctx}/admin/channel/online/"
	};
	johnny.tableBtn(online);
	
	var offline = {
			id : 'offline',
			text  : 'Offline',
			domain : "Page",
			operation : "Offline",
			url : "${ctx}/admin/channel/offline/"
	};
	johnny.tableBtn(offline);
	
});
 
var columnHeader = ['','name', 'selfTemplate.name', 'present','path',''];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var subArray = new Array();
		var value = johnny.getForSelect(json.result[i].id);
 		subArray.push(value);
		var link = "${ctx}/admin/channel/"+json.result[i].id+"/edit/";
		var view = "${ctx}/"+json.result[i].path;
		var inline = "${ctx}/LG-en/24k-editor/"+json.result[i].path+"/";
		subArray.push(json.result[i].name);
		subArray.push(json.result[i].title);
		subArray.push("<span><a href='${ctx}/admin/template/"+json.result[i].selfTemplate.id+"/edit/'>"+json.result[i].selfTemplate.name+"</a></span>");
		subArray.push(json.result[i].present);
		subArray.push(json.result[i].path);
		if (json.result[i].selfTemplate.inlineEdit) {
			var conf = [{
				link : link,
				text : 'Page Setting',
				css   : 'icomoon-icon-pencil'
			},
			{
				link : inline,
				text : 'Inline Edit',
				css   : 'icomoon-icon-pencil-3',
				sub   : [<c:forEach varStatus="loop" var="single"  items="${languages}">{ name :'<c:out value="${single.language}"></c:out>',url :  "${ctx}/LG-"+ '${single.lg}' +"/24k-editor/"+json.result[i].path+"/"}<c:if test="${!loop.last}">,</c:if></c:forEach>]
			},{
				link : view,
				text : 'View',
				css   : 'minia-icon-eye'
				
			}];
			 
		} else {
			var conf = [{
				link : link,
				text : 'Page Setting',
				css   : 'icomoon-icon-pencil'
			},
			{
				link : view,
				text : 'View',
				css   : 'minia-icon-eye',
				sub   : [<c:forEach  varStatus="loop" var="single" items="${languages}">'${single.language}'<c:if test="${!loop.last}">,</c:if></c:forEach>]
			}];
			
		}
			subArray.push(johnny.getGridLink(conf));
			dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}
</script>

<a href="${ctx}/admin/channel/create/" class="btn btn-info"> <span class="icomoon-icon-plus white"></span> New</a></div>
 
                      